<?php
namespace App\Admin\Services;

use App\Models\Car;

class CarService
{
    public static function carJsonSwitch($json_ids)
    {
        $car_title = '';
        $ids = json_decode($json_ids, true);

        if ($ids) {
            $car = Car::whereIn('id', $ids)->pluck('title');

            foreach ($car as $key => $value) {
                if (count($car) - 1 != $key) {
                    $car_title .= $value . '/';
                } else {
                    $car_title .= $value;
                }
            }
        }

        return $car_title;
    }
}